package com.gxa.goods.mapper;

import com.gxa.goods.pojo.Sku;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.Map;

public interface SkuMapper extends Mapper<Sku> {


    @Select("select * from gxa_sku where id=#{id} for update")
    public Sku selectSkuById(String id);

    /**
     * 根据id减去库存
     * */
    @Update("update gxa_sku set num=num-#{num} where id=#{id} and num-#{num2}>=0")
    public void updateItemStock(@Param("num")Integer num,@Param("id")String id,@Param("num2")Integer num2);

    /**
     * 根据id加库存
     * */
    @Update("update gxa_sku set num=num+#{num} where id=#{id}")
    public void addItemStock(Map map);


}
